/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package inf3791.calendarsystem.others;

import inf3791.calendarsystem.others.components.editing.AppointmentEditForm;
import inf3791.calendarsystem.others.panels.calendar.CalendarPanel;
import inf3791.calendarsystem.shared.Appointment;
import java.awt.CardLayout;
import java.awt.Dialog;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

/**
 *
 * @author Jonas Weber
 */
public class OthersMainDialog extends javax.swing.JFrame {

    private final static String P_CALENDAR = "calendar";
    
    /**
     * Creates new form OthersMainDialog
     */
    public OthersMainDialog() {
        super("Calendar-System");
        initComponents();

        realContentPane.add(new CalendarPanel(), P_CALENDAR);
        
        Appointment a1 = new Appointment();
        a1.setTime(new Date());
        a1.setTitle("Title");
        /*appointmentWidget2.setAppointment(a1);*/

    }
    
    private void setDay(inf3791.calendarsystem.others.components.calendar.DayClickedEvent evt)
    {
        Logger.getLogger(this.getClass().getCanonicalName()).log(Level.INFO, evt.getDay() + ". " + evt.getMonth() + ". " + evt.getYear() + " / " + evt.getDate());
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        othersMainMenu1 = new inf3791.calendarsystem.others.OthersMainMenu();
        realContentPane = new javax.swing.JPanel();
        clockWidget1 = new inf3791.calendarsystem.others.components.ClockWidget();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        othersMainMenu1.addMenuClickedListener(new inf3791.calendarsystem.others.OthersMainMenu.MainMenuClickedListener() {
            public void addnewevent(inf3791.calendarsystem.others.OthersMainMenu.MainMenuClickedEvent evt) {
                othersMainMenu1Addnewevent(evt);
            }
            public void appointments(inf3791.calendarsystem.others.OthersMainMenu.MainMenuClickedEvent evt) {
            }
            public void calendar(inf3791.calendarsystem.others.OthersMainMenu.MainMenuClickedEvent evt) {
                othersMainMenu1Calendar(evt);
            }
            public void home(inf3791.calendarsystem.others.OthersMainMenu.MainMenuClickedEvent evt) {
            }
        });

        realContentPane.setLayout(new java.awt.CardLayout());

        clockWidget1.setFont(new java.awt.Font("Dialog", 1, 48)); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(clockWidget1, javax.swing.GroupLayout.DEFAULT_SIZE, 1085, Short.MAX_VALUE)
                        .addGap(199, 199, 199))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(othersMainMenu1, javax.swing.GroupLayout.PREFERRED_SIZE, 299, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(realContentPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(clockWidget1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(othersMainMenu1, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE)
                        .addGap(264, 264, 264))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(realContentPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void othersMainMenu1Calendar(inf3791.calendarsystem.others.OthersMainMenu.MainMenuClickedEvent evt) {//GEN-FIRST:event_othersMainMenu1Calendar
        ((CardLayout) realContentPane.getLayout()).first(realContentPane);
    }//GEN-LAST:event_othersMainMenu1Calendar

    private void othersMainMenu1Addnewevent(inf3791.calendarsystem.others.OthersMainMenu.MainMenuClickedEvent evt) {//GEN-FIRST:event_othersMainMenu1Addnewevent
        final AppointmentEditForm aef = new AppointmentEditForm() {

            @Override
            protected Appointment getInitialAppointment() {
                return null;
            }

            @Override
            protected String getButton1Text() {
                return "Submit";
            }

            @Override
            protected String getButton2Text() {
                return "Cancel";
            }

            @Override
            protected void onButton1(Appointment x) {
                
            }

            @Override
            protected void onButton2(Appointment x) {
                setVisible(false);
            }

            @Override
            protected String getWindowTitle() {
                return "Add new Appointment";
            }
        };
        aef.setVisible(true);
    }//GEN-LAST:event_othersMainMenu1Addnewevent

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(OthersMainDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(OthersMainDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(OthersMainDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(OthersMainDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new OthersMainDialog().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private inf3791.calendarsystem.others.components.ClockWidget clockWidget1;
    private inf3791.calendarsystem.others.OthersMainMenu othersMainMenu1;
    private javax.swing.JPanel realContentPane;
    // End of variables declaration//GEN-END:variables
}
